package com.youtills.resource;

/**
 * TODO - !!!doc me!!!
 *
 * @author ravi.chiluveru
 * @since 23.0 (10/15/14)
 */
public interface ResourceLink {

    String getLinkName();
    <T extends Resource> Class<T> getLeftClass();
    <T extends Resource> Class<T> getRightClass();

    public class Builder<T extends Resource> {

        private String linkName;
        private Class<T> leftClass;
        private Class<T> rightClass;

        public Builder setLinkName(String linkName) {
            this.linkName = linkName;
            return this;
        }
        public String getLinkName() {
            return linkName;
        }

        public ResourceLink build() {
            return new Impl(linkName, leftClass, rightClass);
        }

        public Class<T> getLeftClass() {
            return leftClass;
        }

        public Builder setLeftClass(Class<T> leftClass) {
            this.leftClass = leftClass;
            return this;
        }

        public Class<T> getRight() {
            return rightClass;
        }

        public Builder setRightClass(Class<T> rightClass) {
            this.rightClass = rightClass;
            return this;
        }
    }

    class Impl<T extends Resource> implements ResourceLink {
        private final String linkName;
        private final Class<T> left;
        private final Class<T> right;

        private Impl(String linkName,  Class<T> left, Class<T> right) {
            this.linkName = linkName;
            this.left = left;
            this.right = right;
        }

        @Override
        public String getLinkName() {
            return linkName;
        }

        @Override
        public Class<T> getLeftClass() {
            return this.left;
        }

        @Override
        public Class<T> getRightClass() {
            return this.right;
        }
    }

}
